// pages/store/store.js
var app = getApp()
let api = require('../../../api/api.js')

Page({
  /**
   * 页面的初始数据
   */
  data: {
    hide:false
  },
  formSubmit: function(e) {
    var that = this
    console.log(e)
    wx.request({
      url: 'https://www.900yeah.com/api/dblong/leveladd',
      data: {
        name: e.detail.value.name,
        address: e.detail.value.address,
        pcharge: e.detail.value.pcharge,
        number: e.detail.value.number,
        introducer: e.detail.value.introducer,
        mobile: app.globalData.userInerInfo.number
      },
      method: 'POST',
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: function(res) {
        app.globalData.userInerInfo.partner = 1
        app.globalData.userInerInfo.d_num = app.globalData.userInerInfo.d_num + 1
        console.log(res)
        if (res.data.description == 200) {
          wx.navigateTo({
            url: '/pages/A/generate/generate?id=' + res.data.result.name + '&img=' + res.data.result.url
          })
        } else {
          wx.showModal({
            title: '提示',
            content: res.data.code,
            showCancel: false
          })
        }
      },
    })
    this.setData({
      hide: true
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})